home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Source Code
/
OpenDoc
/
ProcessMap
/
CPProcessMap.cpp
next >
Wrap
Text File
|
1995-04-28
|
8KB
|
271 lines
/*
File: CPProcessMap.cpp
Contains: CPProcessMap OpenDoc part editor class implementation.
Built using PartMaker, then modified.
Written by: PartMaker
Change History (most recent first):
<3> 4/14/95 JS Updated for Developer Release 2
<4> 3/8/95 JS Updated to b1c13/c14
<3> 3/8/95 RA Add tokenized kODPresDefault param to RegisterWindow().
<2> 2/21/95 RA Add kODFrameObject param to RegisterWindow().
<1> 2/2/95 RA first checked in
<0> PartMaker source by E. Soldan, T. Çelik, J. Alfke, R. Adkins, J. Schalk
*/
#ifndef _PROCESSMAP_
#include "CPProcessMap.h"
#endif
//----------------------------------------------------------------------------------------
CPProcessMap::CPProcessMap()
{
// CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Constructor
EnteringMethod("\pCPProcessMap::CPProcessMap");
fDirty = kODFalse;
fWindowID = 0;
fSession = kODNULL;
fSelf = kODNULL;
fStorageUnit = kODNULL;
fMenuBar = kODNULL;
fDraftKey = 0;
// Note that fDisplayFrames is a static field, and therefore
// its constructor is automatically called before
// CPProcessMap constructor.
}
//----------------------------------------------------------------------------------------
CPProcessMap::~CPProcessMap()
{
// CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Destructor
EnteringMethod("\pCPProcessMap::~CPProcessMap");
}
//----------------------------------------------------------------------------------------
void CPProcessMap::Release(Environment* ev)
{
// CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Release
EnteringMethod("\pCPProcessMap::Release");
if (fSelf->GetRefCount(ev) == 1) {
// Here is where you would unregister idle time for the part if
// have registered time. Note that if you unregister without
// registering, OpenDoc will crash. It's not just a simple
// look-up-and-if-there-remove kind of operation.
// Note that if you unregister idle here, OpenDoc will need to
// call Release (here) due to it. This means that when we call
// to unregister the idle, we are nesting calls to Release.
// Due to this, I return out of each case, just to make the
// flow of control of the call(s) to Release more straightforward.
// Note that if you are going to use idle registration, you will
// need to include "Disptch.h"
fSession->GetDispatcher(ev)->UnregisterIdle(ev,fSelf,NULL);
return;
}
}
//----------------------------------------------------------------------------------------
ODID CPProcessMap::Open(Environment* ev, ODFrame* frame)
{
// CodeWarrior: Cmd-Click or Search:Find Definition • Explain_Open
EnteringMethod("\pCPProcessMap::Open");
ODID windowID;
ODWindow* window = kODNULL;
if (frame) // Doing a View As Window or Open Root
{
if (frame->IsRoot(ev))
{
windowID = this->PrivOpenSavedWindow(ev, frame);
}
else
{
//ClockFrame* clockFrame = (ClockFrame*) frame->GetPartInfo(ev);
//if (clockFrame)
// windowID = clockFrame->ViewInWindow(ev);
}
}
else
{
windowID = this->PrivOpenInitialWindow(ev);
}
return windowID;
}
//----------------------------------------------------------------------------------------
ODWindow* CPProcessMap::PrivCreateWindow(Environment *ev,ODFrame* sourceFrame)
{
// get rectangle
Rect windRect;
const ODSShort kOnePageWidth = 600;
::SetRect(&windRect, 4, GetMBarHeight() + 24,
ODQDGlobals.screenBits.bounds.right - 64,
ODQDGlobals.screenBits.bounds.bottom - 4);
if (windRect.right - windRect.left > kOnePageWidth)
windRect.right = windRect.left + kOnePageWidth;
// get title
Str255 windowTitleStr;
ODName* partName = ODGetPOName(ev, fSelf, kODNULL);
IntlToPStr(partName, (StringPtr)&windowTitleStr);
DisposeIText(partName);
ODPlatformWindow platformWindow = ::NewCWindow(kODNULL,
&windRect,
windowTitleStr,
false,
this->PrivWantResizableWindow() ? zoomDocProc : zoomNoGrow,
(WindowPtr)-1L,
true,
kODNULL);
ODBoolean isRoot = ((sourceFrame == kODNULL) || sourceFrame->IsRoot(ev));
ODWindow* window = fSession->GetWindowState(ev)->RegisterWindow(ev,
platformWindow, // newWindow
isRoot ? // Persistent
kODFrameObject: // Non-Persistent
kODNonPersistentFrameObject, // frameType
isRoot, // isRootWindow
this->PrivWantResizableWindow(), // isResizable
kODFalse, // isFloating
kODTrue, // shouldSave
fSelf, // rootPart
fSession->Tokenize(ev, kODViewAsFrame), // viewType
fSession->Tokenize(ev, kODPresDefault), // presentation
sourceFrame); // sourceFrame
return window;
}
//----------------------------------------------------------------------------------------
ODID CPProcessMap::PrivOpenInitialWindow(Environment* ev)
{
ODWindow* window = this->PrivCreateWindow(ev, kODNULL);
ODID windowID = window->GetID(ev);
window->Open(ev);
window->Show(ev);
window->Select(ev);
return windowID;
}
//----------------------------------------------------------------------------------------
ODID CPProcessMap::PrivOpenSavedWindow(Environment* ev, ODFrame* frame)
{
ODWindow* window = kODNULL;
WindowProperties props;
if (BeginGetWindowProperties(ev, frame, &props))
{
ODPlatformWindow platformWindow = NewCWindow(kODNULL, &(props.boundsRect), props.title,
kODFalse, props.procID, (WindowPtr)-1L, props.hasCloseBox, props.refCon);
window = fSession->GetWindowState(ev)->RegisterWindowForFrame(ev,
platformWindow,
frame,
props.isRootWindow, // Keeps draft open
kODTrue, // Is resizable
kODFalse, // Is floating
kODTrue, // shouldSave
props.sourceFrame);
EndGetWindowProperties(ev, &props); // Release source frame
window->Open(ev);
window->Show(ev);
return window->GetID(ev);
}
else
return 0;
}
//----------------------------------------------------------------------------------------
ODBoolean CPProcessMap::PrivWantResizableWindow()
{
return kODFalse;
}
//----------------------------------------------------------------------------------------
void CPProcessMap::ReleaseAll(Environment* ev)
{
// CodeWarrior: Cmd-Click or Search:Find Definition • Explain_ReleaseAll
EnteringMethod("\pCPProcessMap::ReleaseAll");
if (fMenuBar != kODNULL)
fMenuBar->Release(ev);
}
//----------------------------------------------------------------------------------------
void CPProcessMap::PrivInvalAllDisplayFrames(Environment* ev)
{
// This is just a CPProcessMap utility method.
for (FrameLink *fl = fDisplayFrames.First(); fl->Frame(); fl = fl->Next())
fl->Frame()->Invalidate(ev, kODNULL, kODNULL);
}
//----------------------------------------------------------------------------------------
// Storage protocol
//----------------------------------------------------------------------------------------
void CPProcessMap::IncrementRefCount(Environment* ev)
{
// CodeWarrior: Cmd-Click or Search:Find Definition • Explain_IncrementRefCount
EnteringMethod("\pCPProcessMap::IncrementRefCount");
}
//----------------------------------------------------------------------------------------
void CPProcessMap::CloneInto(Environment* ev, ODDraftKey key,
ODStorageUnit* destinationSU, ODFrame* initiatingFrame)
{
// CodeWarrior: Cmd-Click or Search:Find Definition • Explain_CloneInto
EnteringMethod("\pCPProcessMap::CloneInto");
// We must first verify that we've never written to this storage unit.
// If we have, we should do nothing, otherwise we need to write out
// the current state of the part content.
if ( destinationSU->Exists(ev, kODPropContents, kProcessMapKind, 0) == kODFalse )
{
// Add the properties we need to successfully externalize
// ourselves into the destination storage unit.
this->PrivCheckAndAddProperties(ev, destinationSU);
// Write out the part's state information.
this->PrivExternalizeStateInfo(ev, destinationSU, key, initiatingFrame);
// Write out the part's content.
this->PrivExternalizeContent(ev, destinationSU);
}
}
//----------------------------------------------------------------------------------------
ODSize CPProcessMap::Purge(Environment* ev, ODSize size)
{
//
ODUnused(size);
EnteringMethod("\pCPProcessMap::Purge");
// CPProcessMap doesn't do anything here.
return 0;
}